package com.quanxiaoha.weblog.common.domain.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.quanxiaoha.weblog.common.domain.dos.ArticleCategoryRelDO;
import com.quanxiaoha.weblog.common.domain.dos.ArticleContentDO;

public interface ArticleCategoryRelMapper extends BaseMapper<ArticleCategoryRelDO> {

    /**
     * 根据文章id删除记录
     *
     * @param articleId
     */
    default void delByArticleId(Long articleId) {
        this.delete(new LambdaQueryWrapper<ArticleCategoryRelDO>().eq(ArticleCategoryRelDO::getArticleId, articleId));
    }


    /**
     * 根据文章id获取其分类
     *
     * @param articleId
     * @return
     */
    default ArticleCategoryRelDO getByArticleId(Long articleId) {
        return this.selectOne(new LambdaQueryWrapper<ArticleCategoryRelDO>().eq(ArticleCategoryRelDO::getArticleId, articleId));
    }

}